﻿Imports System.Drawing.Drawing2D
Imports System.Drawing
Imports System.Drawing.Text
Public Class CircleAxesTitle
    Inherits WindBase
    Public TitleName As String
    Private fontFamily As New FontFamily(New GenericFontFamilies)
    ''' <summary>
    ''' 字体对象
    ''' </summary>
    ''' <remarks></remarks>
    Public TitleFont As New Font(fontFamily, 10, FontStyle.Regular, GraphicsUnit.Pixel)
    ''' <summary>
    ''' 字颜色
    ''' </summary>
    ''' <remarks></remarks>
    Public TitleColor As Integer = Color.Black.ToArgb
    Public Sub DrawTitle(ByVal grap As Graphics, ByVal R As Single, ByVal Location As PointF)
        'rect 参数为来表示除去坐标刻度及坐标标注以外的区域
        If Visible Then '如果可见就绘制坐标轴的轴线
            Dim TitleFormat As New StringFormat
            Dim TitleBrush As New SolidBrush(Color.FromArgb(TitleColor))
            TitleFormat.Alignment = StringAlignment.Center
            Dim myMatrix As New Matrix()
            Dim TextHeight As Double '字的高度
            TextHeight = grap.MeasureString("E", TitleFont).Height * PannelSetting.gScale
            Dim graphicsContainer As GraphicsContainer '嵌套的 Graphics 容器
            graphicsContainer = grap.BeginContainer() '嵌套的 Graphics 容器

            myMatrix.Translate(Location.X + R + TextHeight, Location.Y + TextHeight / 2)
            myMatrix.Rotate(0)
            myMatrix.Scale(PannelSetting.gScale, PannelSetting.gScale) '将字体按比例回放
            myMatrix.Multiply(New Matrix(1, 0, 0, -1, 0, 0))
            grap.Transform = myMatrix
            grap.DrawString("E", TitleFont, TitleBrush, 0, 0, TitleFormat)
            grap.EndContainer(graphicsContainer) '退出绘图容器



            myMatrix = New Matrix()
            graphicsContainer = grap.BeginContainer() '嵌套的 Graphics 容器
            myMatrix.Translate(Location.X, Location.Y - (R + TextHeight / 2))
            myMatrix.Rotate(0)
            myMatrix.Scale(PannelSetting.gScale, PannelSetting.gScale) '将字体按比例回放
            myMatrix.Multiply(New Matrix(1, 0, 0, -1, 0, 0))
            grap.Transform = myMatrix
            grap.DrawString("S", TitleFont, TitleBrush, 0, 0, TitleFormat)
            grap.EndContainer(graphicsContainer) '退出绘图容器

            myMatrix = New Matrix()
            graphicsContainer = grap.BeginContainer() '嵌套的 Graphics 容器
            myMatrix.Translate(Location.X - (R + TextHeight), Location.Y + TextHeight / 2)
            myMatrix.Rotate(0)
            myMatrix.Scale(PannelSetting.gScale, PannelSetting.gScale) '将字体按比例回放
            myMatrix.Multiply(New Matrix(1, 0, 0, -1, 0, 0))
            grap.Transform = myMatrix
            grap.DrawString("W", TitleFont, TitleBrush, 0, 0, TitleFormat)
            grap.EndContainer(graphicsContainer) '退出绘图容器


            myMatrix = New Matrix()
            graphicsContainer = grap.BeginContainer() '嵌套的 Graphics 容器
            myMatrix.Translate(Location.X, Location.Y + (R + 3 * TextHeight / 2))
            myMatrix.Rotate(0)
            myMatrix.Scale(PannelSetting.gScale, PannelSetting.gScale) '将字体按比例回放
            myMatrix.Multiply(New Matrix(1, 0, 0, -1, 0, 0))
            grap.Transform = myMatrix
            grap.DrawString("N", TitleFont, TitleBrush, 0, 0, TitleFormat)
            grap.EndContainer(graphicsContainer) '退出绘图容器


        End If
    End Sub

End Class
